<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<base href="<%=basePath%>">
<link rel="stylesheet" href="css/bootstrap.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
	<form action="" class="well" id="form" method="post" style="width:320px;margin-left:auto;margin-right:auto">
		用户名<label for="name"><input type="text" name="name" id="name" required="required" onblur="chkecname()"/></label>
		 密码<label for="password"><input type="password" name="password" id="password"  required="required"/> </label>
		确认密码<label><input type="password" name="surepassword" id="surepassword" onkeyup="subs(event)" required="required"/> </label>
		<h2 style="text-align:center;">
		<input type="button" value="提交" class="btn btn-danger" onclick="sub()" />
		<input type="hidden" id="msg">
		 <input type="button" value="登录" class="btn btn-primary" onclick="reg()"/>
		</h2>
	</form>
	<script type="text/javascript">
	function subs(event){
		if(event.keyCode==13&&($("#msg").val()=='ok')){
			sub();
		}
	}
	function chkecname(){
		$.post("checkname.jspx",{name:name}, function(data){
			$("#msg").val(data);
			});
	}
	function sub(){
		var name=document.getElementById("name").value;
		var password=document.getElementById("password").value;
		var surepassword=document.getElementById("surepassword").value;
		if((name.length<20&&name.length>6)&&(password.length<20&&password.length>6)&&(surepassword==password)&&($("#msg").val()=='ok')){
			$.post("reg.jspx",{name:name,password:password}, function(data){
				if(data=="ok"){
				window.location="login-success.jsp";
				}else{
				window.location="index.jsp";
				}
				 });
		}else{
			alert("error");
		}
	}
	function reg(){
	window.location="index.jsp";
	}
	</script>
</body>
</html>
